package com.itheima.controller;

import com.itheima.common.BarChartData;
import com.itheima.common.R;
import com.itheima.service.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin (value = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE})
@RestController
@Slf4j
public class StatisticsController {
    @Autowired
    private CustomerService customerService;


    /**
     * 会员年龄统计
     *
     * @return BarChartData
     */
    @GetMapping ("/customer/ageReport")
    public R ageReport() {
        BarChartData barChartData = customerService.ageReport();
        return R.ok(barChartData);
    }
}
